import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const routes = [
  {
    path: '',
    name: 'index_box',
    component: () => import('../views/index_box.vue'),
    redirect: '/',
    // 用于路由跳转
    children: [
      {
        path: '/',
        name: 'Index',
        component: () => import('../views/Index.vue')
      },
      // 实时问答
      {
        path: '/Problem',
        name: 'Problem',
        component: () => import('../views/Problem.vue')
      },
      // 实时问答详情(评论)
      {
        path: '/Problem_details',
        name: 'Problem_details',
        component: () => import('../views/Problem_details.vue')
      },
      // 代码知识
      {
        path: '/Knowledge',
        name: 'Knowledge',
        component: () => import('../views/Knowledge.vue')
      },
      // 技术社区
      {
        path: '/Technology',
        name: 'Technology',
        component: () => import('../views/Technology.vue')
      },
      {
        // 素材库页面
        path: '/Materlibrary',
        name: 'Materlibrary',
        component: () => import('../views/Materlibrary.vue')
      },
      {
        path: '/home',
        name: 'Home',
        component: () => import('../views/Home.vue')
      },
      {
        path: '/Example',
        name: 'Example',
        component: () => import('../views/Example.vue')
      },
      {
        // 实例展示
        path: '/Exhibition',
        name: 'Exhibition',
        component: () => import('../views/Exhibition.vue')
      },
      {
        // 电商淘宝
        path: '/Material',
        name: 'Material',
        component: () => import('../views/Material.vue')
      },
      {
        path: '/Sourexq',
        name: 'Sourexq',
        component: () => import('../views/Sourexq.vue')
      }
    ]
  },
  {
    path: '*',
    component: () => import('@/views/404')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  localStorage.setItem('get', to.query.get)
  next()
})

export default router
